package com.netty.exmple.zerocopy;

import java.io.DataInputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class OldIOServer {
    public static void main(String[] args) throws Exception {
        ServerSocket serverSocket = new ServerSocket(8899);
        while (true) {
            Socket socket = serverSocket.accept();
            DataInputStream dataInputStream = new DataInputStream(socket.getInputStream());
            try {
                byte[] byteArray = new byte[4096];
                long readCount = 0L;
                long totalCount = 0L;
                while (true) {
                    readCount = dataInputStream.read(byteArray, 0, byteArray.length);
                    totalCount += readCount;
                    if (-1 == readCount) break;
                }
                System.out.println("发送的总字节数：" + totalCount);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
